package com.hut.oa.model.bean;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.format.annotation.DateTimeFormat;

/**
 * 请假申请
 * @author 熊涛
 *
 */
@Entity
@Table(name="apply_leave")
public class ApplyLeave {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="al_id",nullable=false)
	private Long id;//请假id
	
	@Column(name="al_reason",nullable=false)
	private String reason;//请假事由
	
	@Temporal(TemporalType.DATE)
	@DateTimeFormat(pattern="yyyy-MM-dd")
	@Column(name="al_go_time",nullable=false)
	private Date goTime;//请假时间
	
	@Temporal(TemporalType.DATE)
	@DateTimeFormat(pattern="yyyy-MM-dd")
	@Column(name="al_back_time",nullable=false)
	private Date backTime;//返回时间
	
	@JoinColumn(name="al_apply_id",nullable=false)
	@OneToOne(cascade=CascadeType.ALL)
	private Apply apply;//通用申请
	
	public ApplyLeave() {
		// TODO Auto-generated constructor stub
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public Date getGoTime() {
		return goTime;
	}

	public void setGoTime(Date goTime) {
		this.goTime = goTime;
	}

	public Date getBackTime() {
		return backTime;
	}

	public void setBackTime(Date backTime) {
		this.backTime = backTime;
	}

	public Apply getApply() {
		return apply;
	}

	public void setApply(Apply apply) {
		this.apply = apply;
	}

	@Override
	public String toString() {
		return "ApplyLeave [id=" + id + ", reason=" + reason + ", goTime=" + goTime + ", backTime=" + backTime + "]";
	}

}
